#ifndef DOCUMENT_H
#define DOCUMENT_H

#include <BXmlNode>
#include <BXmlDocument>
#include <BTreeWidget>
#include <BTextEdit>
#include <BFile>
#include <BWidget>

using namespace BWE;

class DocumentEdit : public BWidget
{
public:
	DocumentEdit(const BString& title);
	~DocumentEdit();

	bool open(const BString& fileName);
	bool load(const BString& htmlFileName);
	bool save();

protected:
	int strideMethodContent(const BString& text, int pos);
	void createDescription(BXmlNode* body);
	void collectMethods(BXmlNode* body, const BString& text, int& pos, int& number);
	void attachPublicMethods(BTreeItem* item);
	void attachProtectedMethods(BTreeItem* item);
	void applyEditedDocument();

protected:
	void procItemClicked(BObject* object, const BValue& value);

protected:
	virtual void updateEvent(const BEvent& event);

private:
	BString				_fileName;
	BString				_htmlFileName;
	BXmlNodeHolder		_headRoot;
	BXmlNodeHolder		_htmlRoot;

	BTreeItemHolder		_item;
	BTreeWidget*		_treeWidget;
	BLabel*				_itemLabel;
	BTextEdit*			_documentEdit;
	BTextEdit*			_seeAlsoEdit;

};

#endif
